import request from "../request"
import qs from 'qs'
// 获取验证码
interface UserSend {
    phone: string
}

// 发送注册短信验证码
export const SendSMSAPI = (params: UserSend): Promise<any> => request.post('/sendSMS', qs.stringify(params))

// 登录
export const PhoneReginAPI = (params: phoneParams): Promise<TokenObject> => request.post('/phoneRegin', qs.stringify(params))
    // 微信扫码登录请求
export const WeiXinLoginAPI = (params:WeiXinLoginParams): Promise<TokenObject> => request.post("/wechatUsers/PCLogin", qs.stringify(params))
    // 手机关联微信
export const BindingAPI = (params:BindingParams): Promise<TokenObject> => request.post("/wechatUsers/binding", qs.stringify(params))
// 获取用户信息
export const UserProfilesAPI = () => request.get('/shop/userProfiles')

// 请求精品数据
export const JingPinAPI = (): RES<RecObject> => request.get('/products/recommend')

// 请求热门兑换数据
export const ReMenAPI = (): RES<RecObject> => request.get('/products/hot')

// 商品详情
export const GoodsDetailsAPI = (id: number): RES<Products> => request.get('/products/' + id)

// 加入购物车
export const AddShopAPI = (params: AddShopParam): RES<AddShopObject> => request.post('/shop/carts/add', qs.stringify(params))

// 商品搜索（含首页的“更多”）
export const GoodsSearchAPI = (params: SearchObject): Promise<ProductObject> => request.get('/products', { params })
// 查看购物车
export const ShopCartsAPI = (): Promise<CartObject> => request.get("/shop/carts")
// 删除购物车商品
export const DeleteCartsAPI = (id:number)=> request.delete(`/shop/carts?productIds=${id}`)